<template>
  <div class="AddOrUpdate_main add_container column_three">
    <div class="main_main">
      <el-tabs v-model="activeName">
        <el-tab-pane label="基本信息" name="first">
          <el-form ref="form" :model="formData" :rules="rules" :inline="true">
            <el-form-item label="发货单号" prop="code">
              <CodeRuleInput
                :band-value.sync="formData.code"
                table-name="sale_deliver_goods"
                column-name="code"
                :is-edit="id"
              />
            </el-form-item>
            <el-form-item label="制单人员">
              <el-input v-model="formData.deliverName" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="制单日期">
              <el-date-picker
                v-model="formData.deliverTime"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                :editable="false"
              />
            </el-form-item>
            <!-- <el-form-item label="销售订单号" class="clickChoose" prop="saleOrderCode">
              <el-input v-model="formData.saleOrderCode" placeholder="暂无" readonly />
              <a
                class="clickChoose_button"
                @click.prevent="chooseOrders"
              >
                <svg-icon icon-class="选择弹框" />
              </a>
            </el-form-item> -->
            <el-form-item label="客户名称" class="clickChoose" prop="customerName">
              <!-- <el-select
            v-model="formData.saleCustomerId"

            clearable
            filterable
            placeholder="请选择"
            @change="changePeople"
          >
            <el-option
              v-for="item in peopleList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select> -->
              <el-input v-model="formData.customerName" placeholder="请选择" readonly />
              <a
                class="clickChoose_button"
                @click.prevent="choosePeople"
              >
                <svg-icon icon-class="选择弹框" />
              </a>
            </el-form-item>
            <el-form-item label="交货方式" prop="deliveryTypeLabel" class="clickChoose">
              <el-input v-model="formData.saleDeliverInformation.deliveryTypeLabel" placeholder="暂无" readonly :disabled="!isCanSelect" />
              <a
                class="clickChoose_button"
                @click.prevent="chooseWays"
              >
                <svg-icon icon-class="选择弹框" />
              </a>
            </el-form-item>
            <el-form-item label="收货人">
              <el-input v-model="formData.saleDeliverInformation.consigneeOne" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="运费承担方" prop="freightBy">
              <DictSelect
                :band-value.sync="formData.freightBy"
                dict-type="freightBy"
              />
            </el-form-item>
            <el-form-item label="费用">
              <el-input v-model="formData.cost" type="number" placeholder="请输入" clearable />
            </el-form-item>
            <el-form-item label="附件" class="double">
              <FileManageFull
                :file-names="formData.fileName"
                :file-real-names="formData.fileRealName"
                :file-urls="formData.url"
                :row-index="1"
                @fileName="setFileName"
              />
            </el-form-item>
            <el-form-item label="备注" class="double">
              <el-input
                v-model="formData.remark"
                type="textarea"
                placeholder="请输入"
                maxlength="200"
                show-word-limit
              />
            </el-form-item>
          </el-form>
          <div class="formItem_header">
            <!-- 订单明细 -->
            <div />
            <div v-if="materialName.length > 0" class="MaterialName">
              <span class="MaterialNameIcon el-icon-warning" />
              <div v-for="item in materialName" :key="item" class="MaterialNameName">
                <span>{{ item }}</span>
              </div>
              <div class="MaterialNameText">物料暂无库存，无法发货！</div>
            </div>
            <div v-else />
            <div class="formItem_header_operate">
              <a class="formItem_header_operate_item" @click="addRow">
                <svg-icon icon-class="新增" />
                <div class="item_name">添加</div>
              </a>
              <a class="formItem_header_operate_item delete" @click="deleteRow">
                <svg-icon icon-class="删除" />
                <div class="item_name">删除</div>
              </a>
            </div>
          </div>
          <div
            ref="table_container"
            class="table_container draggableTable"
          >
            <el-table
              ref="table"
              v-loading="loading"
              :data="listData"
              :height="tableHeight"
              border
              :cell-class-name="cellClassName"
              :row-class-name="rowClassName"
              :header-cell-class-name="headerCellClassName"
              :span-method="objectSpanMethod"
              @sort-change="(column)=>{sortChange(column, this)}"
              @selection-change="(val)=>{selectionChange(val, this)}"
            >
              <el-table-column type="selection" align="center" />
              <el-table-column label="销售订单" min- width="120" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <span>{{ scope.row.saleOrderCode }}</span>
                </template>
              </el-table-column>
              <el-table-column label="订单数量" min- width="80" prop="orderNumber">
                <template slot-scope="scope">
                  <span>{{ scope.row.orderNumber }}</span>
                </template>
              </el-table-column>
              <el-table-column label="已发数量" min- width="80" prop="alreadyDeliverNumber">
                <template slot-scope="scope">
                  <span>{{ scope.row.alreadyDeliverNumber }}</span>
                </template>
              </el-table-column>
              <el-table-column label="未发数量" min- width="80" prop="orderNumber">
                <template slot-scope="scope">
                  <span>{{ scope.row.willDeliverNumber }}</span>
                </template>
              </el-table-column>
              <el-table-column label="客户交期" min-width="120" prop="saleCustomerDeliveryTime">
                <template slot-scope="scope">
                  <span>{{ scope.row.saleCustomerDeliveryTime }}</span>
                </template>
              </el-table-column>
              <el-table-column label="物料编码" min-width="110" prop="materialCode" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <span>{{ scope.row.materialCode }}</span>
                </template>
              </el-table-column>
              <el-table-column label="物料名称" min-width="125" prop="materialName" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <span>{{ scope.row.materialName }}</span>
                </template>
              </el-table-column>
              <el-table-column label="规格型号" min-width="120" prop="materialModel" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <span>{{ scope.row.materialModel }}</span>
                </template>
              </el-table-column>
              <el-table-column label="物料单位" min-width="80" prop="materialUnitName">
                <template slot-scope="scope">
                  <span>{{ scope.row.materialUnitName }}</span>
                </template>
              </el-table-column>
              <el-table-column label="库存数量" min-width="80" prop="materialInventory">
                <template slot-scope="scope">
                  <span>{{ scope.row.materialInventory }}</span>
                </template>
              </el-table-column>
              <el-table-column label="备注" min-width="180" prop="remark">
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.remark"
                    placeholder="请输入"
                    clearable
                  />
                </template>
              </el-table-column>
              <el-table-column label="本次发货数量" min-width="130" prop="returnNumber">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.deliverNumber" placeholder="请输入" clearable />
                </template>
              </el-table-column>
              <!-- <el-table-column label="客户订单号" min-width="120" prop="saleCustomerOrderCode">
                <template slot-scope="scope">
                  <span>{{ scope.row.saleCustomerOrderCode }}</span>
                </template>
              </el-table-column> -->

              <!-- <el-table-column label="客户料号" min-width="100" prop="saleCustomerMaterialCode">
                <template slot-scope="scope">
                  <span>{{ scope.row.saleCustomerMaterialCode }}</span>
                </template>
              </el-table-column>
              <el-table-column label="备注" min-width="200" prop="remark">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.remark" placeholder="请输入" clearable />
                </template>
              </el-table-column> -->
            </el-table>
          </div>
        </el-tab-pane>
        <el-tab-pane label="客户信息" name="second">
          <el-form ref="form" :model="formData.saleDeliverInformation" :inline="true">
            <el-form-item label="交货方式">
              <el-input v-model="formData.saleDeliverInformation.deliveryTypeLabel" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="收货人">
              <el-input v-model="formData.saleDeliverInformation.consigneeOne" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="联系方式">
              <el-input v-model="formData.saleDeliverInformation.phone" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="注意事项">
              <el-input v-model="formData.saleDeliverInformation.attentionMatters" placeholder="暂无" disabled />
            </el-form-item>
            <el-form-item label="收货地址" class="double">
              <el-input v-model="formData.saleDeliverInformation.deliveryAddress" placeholder="暂无" type="textarea" disabled />
            </el-form-item>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div class="main_bottom">
      <el-button type="cancel" @click.stop="cancel">取消</el-button>
      <el-button @click.stop="onSubmit('0')">存草稿</el-button>
      <el-button @click.stop="onSubmit('3')">提交</el-button>
    </div>
  </div>
</template>

<script>
import {
  addOrUpdate,
  getInfo
} from '@/api/saleManage/saleSend'
import { getcustMarketInfo } from '@/api/saleManage/saleOrder'
// import chooseOrder from './chooseOrder.vue'
import chooseWay from '../saleOrder/chooseWay.vue'
import moment from 'moment'
import searchMaterial from './searchMaterial.vue'
import { getDictSelects } from '@/api/common/common'
import seachUser from './addUser.vue'
export default {
  name: 'AddOrUpdate',
  props: {
    layerid: {},
    id: {},
    defaultValue: {},
    isAdd: {}
  },
  data() {
    return {
      pageData: {
        pageNum: 1,
        pageSize: 9999,
        orderByColumn: 'updateTime',
        isAsc: 'desc'
      },
      formData: {
        code: '',
        deliverBy: '',
        deliverName: '',
        deliverTime: '',
        saleOrderCode: '',
        saleOrderId: '',
        freightBy: '',
        customerName: '',
        freightByLabel: '',
        cost: '',
        fileName: '',
        fileRealName: '',
        url: '',
        remark: '',
        saleCustomerSendInformationId: '',
        saleDeliverInformation: {
          deliveryTypeLabel: '',
          phone: '',
          attentionMatters: '',
          deliveryAddress: '',
          consigneeOne: ''
        },
        saleCustomerId: '',
        data: [],
        id: '',
        allOrderNumber: ''
      },
      isCanSelect: false,
      statusNum: '',
      showMaterialName: false,
      materialName: [],
      orderList: [],
      selections: [], // 表格当前页所选中的行
      selectionsAll: [], // 表格所有页选中的行
      mainId: 'materialId',
      listData: [],
      tableHeight: '400',
      templateSelection: '',
      tableData: [],
      peopleList: [],
      peopleData: {},
      activeName: 'first',
      customerNameId: '',
      saleOrderId: '',
      spanArr: [], // 存合并行数据的数组
      pos: 0, // 合并行数据数组下标
      rowIndex: 1, // 序号
      loading: false,
      rules: {
        code: [
          { required: true, message: '销售订单号不能为空', trigger: 'blur' }
        ],
        // orderTime: [
        //   { validator: validateOrderTime, trigger: 'change' }
        // ],
        customerName: [
          { required: false, message: '客户名称不能为空', trigger: 'change' }
        ]
      }
    }
  },
  created() {
    this.formData.deliverName = this.$store.state.user.name
    this.formData.deliverBy = this.$store.state.user.userId
    if (!this.id) {
      // 没有id就是新增
      Object.keys(this.defaultValue).forEach((key) => {
        // 给右边数据赋值
        this.formData[key] = this.defaultValue[key]
      })
    } else {
      // 有id就是编辑
      this.getInfo()
      this.formData.id = this.id
    }
  },
  mounted() {
    // this.getList()
    this.formData.deliverTime = moment(new Date()).format('YYYY-MM-DD')
  },
  methods: {
    setFileName(...data) {
      this.formData.fileName = data[0]
      this.formData.fileRealName = data[1]
      this.formData.url = data[2]
    },
    headerCellClassName(data) {
      if (['returnNumber'].indexOf(data.column.property) != -1) {
        return 'column_bt'
      }
    },

    // 合并单元格
    getSpanArr(data) {
      // 重新查询后，要清空行数据数组、序号重置为1
      this.loading = true
      this.spanArr = []
      this.rowIndex = 1
      // 遍历数据，判断前后两条数据是否相同
      data.map((item, index) => {
        if (index == 0) {
          this.spanArr.push(1)
          this.pos = 0
          this.rowIndex++
        } else {
          if (item.materialCode == data[index - 1].materialCode) {
            this.spanArr[this.pos] += 1
            this.spanArr.push(0)
          } else {
            this.spanArr.push(1)
            this.pos = index
            this.rowIndex++
          }
        }
      })
      this.loading = false
    },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 7 || columnIndex === 6 || columnIndex === 10 || columnIndex === 9 || columnIndex === 8) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        // rowspan和colspan都为0，则表示这一行不显示，[x, 1]则表示合并了多少行
        return {
          rowspan: _row,
          colspan: _col
        }
      }
    },
    // 物料不足名称数组去重
    materialNameArr(arr) {
      var newArr = arr.filter(function(item, index) {
        return arr.indexOf(item) === index // 因为indexOf 只能查找到第一个
      })
      return newArr
    },
    // 去除物料名称不足最后一位逗号
    Removecommas(arr) {
      const arrTemp = arr
      if (arrTemp.length > 0) {
        if (arrTemp.indexOf('等') != -1) {
          arrTemp[arrTemp.length - 2] = arrTemp[arrTemp.length - 2].substr(0, arrTemp[arrTemp.length - 2].length - 1)
        } else {
          //
          arrTemp[arrTemp.length - 1] = arrTemp[arrTemp.length - 1].substr(0, arrTemp[arrTemp.length - 1].length - 1)
        }
        this.materialName = arrTemp
      }
    },
    showOrder(data) {
      this.loading = true
      this.customerNameId = data.id
      this.formData.customerName = data.name
      // this.formData.saleCustomerId = data.defaultSaleDeliverInformation.saleCustomerId
      this.formData.saleCustomerId = data.id
      if (data.defaultSaleDeliverInformation) {
        this.formData.saleDeliverInformation = data.defaultSaleDeliverInformation
        this.formData.saleDeliverInformation.deliveryTypeLabel = data.defaultSaleDeliverInformation.deliveryTypeLabel
        this.formData.saleCustomerSendInformationId = data.defaultSaleDeliverInformation.id
        this.formData.saleDeliverInformation.consigneeOne = data.defaultSaleDeliverInformation.consignee
      }
      if (this.formData.saleDeliverInformation.deliveryTypeLabel) {
        this.isCanSelect = true
      }
      getcustMarketInfo({ customerId: data.id, isDefault: '1', noReplace: '1', searchValue: '', id: this.formData.id ? this.formData.id : '' }).then(res => {
        this.materialName = []
        this.listData = []
        const data3 = []
        if (res.data.length > 0) {
          const data2 = this.$deepClone(res.data)
          data2.forEach(item => {
            item.deliverNumber = item.willDeliverNumber !== '/' ? Number(item.willDeliverNumber) : ''
            // if (item.willDeliverNumber == '/') {
            //   item.saleOrderDetailId = item.id
            // }
            // item.saleOrderDetailId = item.id
            // delete item.id
            item['disabled'] = true
            delete item.remark
            if (item.materialInventory && item.materialInventory == '0') {
              if (this.materialName.length < 5) {
                this.materialName.push(item.materialName + ',')
                this.materialName = this.materialNameArr(this.materialName)
              } else {
                this.materialName.push('等')
                this.materialName = this.materialNameArr(this.materialName)
              }
            } else {
              item.deliverNumber = item.willDeliverNumber !== '/' ? Number(item.willDeliverNumber) : ''
              // item.saleOrderDetailId = item.id
              delete item.id
              data3.push(item)
            }
          })
          // this.materialName = this.materialNameArr(this.materialName)
          this.Removecommas(this.materialName)
          this.listData = data3
          this.getSpanArr(data3)
          this.loading = false
        }
      }).finally(() => {
        this.loading = false
      })
      this.$nextTick(() => {
        this.$forceUpdate()
      })
    },
    headStyle() {
      return 'text-align:center'
    },

    handleSelectionChange(e) {
      console.log(e)
    },
    // getList() {
    //   list(this.pageData).then(res => {
    //     this.orderList = res.data
    //   })
    // },
    peopleChoose(data) {
      this.formData.manId = data.map(item => item.userId)
    },
    cellClassName(data) {
      if (data.column.property == 'operate') {
        if (data.rowIndex % 2 == 0) {
          // 单数行
          return 'fixed one'
        } else {
          // 双数行
          return 'fixed two'
        }
      }
    },
    rowClassName({ row, rowIndex }) {
      if (rowIndex == this.tableData.length - 1) {
        return 'addRow'
      }
    },
    removeRow(row) {
      this.tableData.splice(this.tableData.indexOf(row), 1)
    },
    addRow() {
      if (!this.customerNameId) {
        this.$message.warning('请选择客户名称')
        return
      } else {
        // this.saleOrderId = this.listData.map((item) => {
        //   return item.saleOrderId
        // }).toString()
        this.$layer.iframe({
        // 弹框
          content: {
            content: searchMaterial, // 传递的组件对象
            parent: this, // 当前的vue对象
            data: {
              customerNameId: this.customerNameId,
              selectRow: this.listData,
              id: this.id
            } // props
          },
          area: ['1320px', '700px'],
          title: '选择销售发货单明细', // 标题
          shadeClose: false // 点击遮罩是否关闭
        })
      }
    },
    deleteRow() {
      this.selections.forEach(item => {
        this.listData.splice(this.listData.indexOf(item), 1)
      })
      this.selections = []
      this.getSpanArr(this.listData)
    },
    getInfo() {
      getInfo(this.id).then((res) => {
        Object.keys(this.formData).forEach((key) => {
          // 给右边数据赋值
          this.formData[key] = res.data[key]
        })
        this.statusNum = res.data.status
        this.formData.customerName = res.data.saleCustomerListVo.name // 客户名称
        this.customerNameId = res.data.saleCustomerListVo.id // 客户id
        if (res.data.saleDeliverInformation) {
          this.formData.saleDeliverInformation = res.data.saleDeliverInformation
          this.formData.saleDeliverInformation.consigneeOne = res.data.saleDeliverInformation.consignee
        }
        this.materialName = []
        const data2 = JSON.parse(JSON.stringify(res.data.orderDetailList))
        data2.forEach(item => {
          if (item.materialInventory == '0') {
            if (this.materialName.length < 5) {
              this.materialName.push(item.materialName)
              const materialName1 = this.materialName.toString()
              const materialName2 = []
              materialName2.push(materialName1)
              this.materialName = materialName2
            } else {
              const materialNameOne = this.materialName.toString()
              const materialNameTwo = []
              materialNameTwo.push(materialNameOne)
              materialNameTwo.push('等')
              this.materialName = materialNameTwo
            }
          }
        })
        this.listData = this.formData.data
        this.getSpanArr(this.listData)
        if (!this.formData.saleDeliverInformation) {
          this.formData.saleDeliverInformation = {
            deliveryTypeLabel: '',
            consigneeOne: '',
            phone: '',
            deliveryAddress: '',
            attentionMatters: ''
          }
        }
        if (this.formData.saleDeliverInformation.deliveryTypeLabel) {
          this.isCanSelect = true
        }
      })
    },
    chooseWays() {
      if (!this.formData.customerName) {
        return this.$message.warning('请选择客户名称')
      }
      if (!this.isCanSelect) {
        return
      }
      this.$layer.iframe({
        // 弹框
        content: {
          content: chooseWay, // 传递的组件对象
          parent: this, // 当前的vue对象
          data: {
            id: this.formData.saleCustomerId,
            selectionId: this.formData.saleCustomerSendInformationId ? this.formData.saleCustomerSendInformationId : ''
          } // props
        },
        area: ['880px', '650px'],
        title: '选择交货方式', // 标题
        shadeClose: false // 点击遮罩是否关闭
      })
    },
    // 选择客户
    choosePeople() {
      this.$layer.iframe({
        // 弹框
        content: {
          content: seachUser, // 传递的组件对象
          parent: this, // 当前的vue对象
          data: {
            id: this.formData.saleCustomerId ? this.formData.saleCustomerId : '',
            rowId: this.formData.id ? this.formData.id : ''
          } // props
        },
        area: ['880px', '700px'],
        title: '选择客户', // 标题
        shadeClose: false // 点击遮罩是否关闭
      })
    },
    // chooseOrders() {
    //   this.$layer.iframe({
    //     // 弹框
    //     content: {
    //       content: chooseOrder, // 传递的组件对象
    //       parent: this, // 当前的vue对象
    //       data: {
    //         selectionId: this.formData.saleOrderId ? this.formData.saleOrderId : ''
    //       } // props
    //     },
    //     area: ['880px', '650px'],
    //     title: '选择销售订单号', // 标题
    //     shadeClose: false // 点击遮罩是否关闭
    //   })
    // },
    // 提交
    onSubmit(num) {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          const tempArr = []
          const afterData = []
          for (let i = 0; i < this.listData.length; i++) {
            if (tempArr.indexOf(this.listData[i].materialId) === -1) {
              afterData.push({
                materialId: this.listData[i].materialId,
                data: [this.listData[i]]
              })
              tempArr.push(this.listData[i].materialId)
            } else {
              for (let j = 0; j < afterData.length; j++) {
                if (afterData[j].materialId == this.listData[i].materialId) {
                  afterData[j].data.push(this.listData[i])
                  break
                }
              }
            }
          }
          var booleanData = afterData.every((ele, index) => {
            const nums = ele.data.map(item => Number(item.deliverNumber)).reduce((prev, curr) => {
              if (curr) {
                return curr + prev
              } else {
                return prev
              }
            })
            if (nums <= ele.data[0].materialInventory) {
              return true
            } else {
              return false
            }
          })
          if (!this.customerNameId) {
            this.$message.warning('请选择客户名称')
            return
          }
          if (!this.SETTINGS.reg_zero.test(this.formData.cost) && this.formData.cost) {
            this.$message.warning('费用填写不正确')
            return
          }
          // this.getSum(afterData)
          if (this.listData.length == 0) {
            this.$message.warning('请添加销售发货单明细')
            return
          } else if (this.listData && this.listData.filter(item => Number(item.deliverNumber) > Number(item.materialInventory)).length > 0) {
            let messageTextarr = []
            this.listData.map(item => {
              if (Number(item.deliverNumber) > Number(item.materialInventory) > 0) {
                messageTextarr.push(item.materialName)
                if (messageTextarr.length == 4) {
                  messageTextarr.push(item.materialName + '等')
                  this.materialNameArr(messageTextarr)
                } else {
                  this.materialNameArr(messageTextarr)
                }
              }
            })
            this.$message.warning(messageTextarr.toString() + '库存不足')
            messageTextarr = []
            // this.$message.warning('发货数量不能大于库存数量')
            return
          } else if (this.listData && this.listData.filter(item => !item.deliverNumber).length > 0) {
            this.$message.warning('发货数量不能为空')
            return
          } else if (this.listData && this.listData.filter(item => item.deliverNumber == '0').length > 0) {
            this.$message.warning('本次发货数量不可为0')
            return
          } else if (this.listData && this.listData.filter(item => item.deliverNumber && !this.SETTINGS.reg_no_zero.test(item.deliverNumber)).length > 0) {
            this.$message.warning('发货数量未正确填写')
            return
          } else if (this.listData && this.listData.filter(item => item.orderNumber && !this.SETTINGS.reg_no_zero.test(item.orderNumber)).length > 0) {
            this.$message.warning('订单数量未正确填写')
            return
          } else if (!booleanData) {
            this.$message.warning('发货数量总和不能大于库存数量')
            return
          } else {
            this.formData.data = this.$deepClone(this.listData)
            if (num == '1') {
              this.formData.deliverTime = this.formData.deliverTime ? moment(this.formData.deliverTime).format('YYYY-MM-DD') : moment(new Date()).format('YYYY-MM-DD')
            }
            if ((this.statusNum == 5 || this.statusNum == 4) && num == 0) {
            } else {
              this.statusNum = num
            }
            // this.formData.data.forEach(item => {
            //   if (item.willDeliverNumber == '/') {
            //     item.saleOrderDetailId = ''
            //   }
            // })
            addOrUpdate({ ...this.formData, status: this.statusNum }).then((res) => {
              this.$message({
                message: res.msg,
                type: 'success'
              })
              this.$layer.close(this.layerid) // 关闭弹框
              this.$parent.getList() // 调用父组件的刷新方法
              this.customerNameId = ''
            })
          }
        }
      })
    },
    cancel() {
      this.$layer.close(this.layerid) // 关闭弹框
    },

    showWayInfo(data) {
      this.formData.saleCustomerSendInformationId = data.id
      this.formData.saleDeliverInformation.deliveryTypeLabel = data.deliveryTypeLabel
      this.formData.saleDeliverInformation.consigneeOne = data.consignee
      this.formData.saleDeliverInformation.phone = data.phone
      this.formData.saleDeliverInformation.deliveryAddress = data.deliveryAddress
      this.formData.saleDeliverInformation.attentionMatters = data.attentionMatters
    },
    showListData(data) {
      const data2 = this.$deepClone(data)
      data2.forEach(ele => {
        if (!ele.deliverNumber) {
          ele.deliverNumber = Number(ele.orderNumber).toString()
        }
      })
      this.listData = data2
      this.getSpanArr(data2)
    }
  }
}
</script>

<style lang="less" scoped>
/deep/.el-table__body-wrapper {
  border-bottom: 1px solid #dfe6ec;
}
.table_container {
  padding-bottom: 20px !important;
}
.title {
  padding-left: 10px;
  padding-bottom: 20px;
  font-size: 24px;
  width: 100%;
}
.numberComponents {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}
/deep/ .el-input-number.is-controls-right .el-input-number__increase {
  height: 15px;
}
.el-icon-remove {
  font-size: 25px;
  color: red;
  height: 100%;
  width: 100%;
  border: 0px;
  background-color: transparent;
}
/deep/ .el-form-item__content {
  margin-left: 0 !important;
}
/deep/ .el-form-item__label {
  text-align: right;
}
.expand_radio {
  /deep/ .el-form-item__content {
    text-align: left;
  }
}
.expand_container {
  .el-form-item {
    margin-bottom: 10px;
  }
  .expand_file {
    margin-bottom: 0px;
  }

  /deep/ .el-form-item__label {
    width: 130px !important;
  }
  /deep/ .el-form-item__content {
    width: 710px !important;
  }
}
.main_main {
  padding-top: 0px !important;
  .form_padding {
    /deep/ .el-form-item {
      margin-right: 0px;
    }
    /deep/ .el-form-item__label {
      width: 120px !important;
    }
    /deep/ .el-form-item__content {
      width: 270px;
    }
    .remark {
      /deep/ .el-form-item__content {
        width: 690px !important;
        height: 60px;
        overflow-y: auto;
      }
    }
  }
}
/deep/ .el-table th.el-table__cell > .cell {
  position: unset;
}
.order_header{
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  .info_button{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }
}
.MaterialName {
  display: flex;
  padding: 15px;
  flex: 1;
  color:rgb(244,156,31);
  text-align: center;
  font-size: 16px;
  align-items: center;
  margin-bottom: 3px;
.MaterialNameName{
  max-width: 150px;
    overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
  .MaterialNameIcon {
    padding: 2px 5px 0 2px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
/deep/.el-tabs__header {
  width: 100% !important;
  position: absolute;
  z-index: 99999;
}
/deep/ .el-form--inline {
  padding-top: 55px;
}

/deep/ .plTableBox .el-table tr{
  background-color: transparent !important;
}
/deep/ .plTableBox .el-table th{
  background-color: transparent !important;
}
/deep/ .plTableBox .el-table thead{
  color: unset;
}
/deep/ .plTableBox .el-table--striped .el-table__body tr.el-table__row--striped td{
  background-color: #eef0f4;
}
/deep/ .plTableBox .el-table--border td, .plTableBox .el-table--border th, .plTableBox .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed{
  border-right: 1px solid #dfe6ec;
}
</style>
